package win.smartown.mistyle;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.animation.LinearInterpolator;
import android.widget.TextView;

import win.smartown.mistyle.app.main.MainActivity;
import win.smartown.mistyle.base.SuperActivity;
import win.smartown.mistyle.demo.R;
import win.smartown.mistyle.util.JumpUtil;

/**
 * Created by smartown on 2017/4/12 14:02.
 * Desc:欢欢迎页
 */
public class WelcomeActivity extends SuperActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        final TextView timerTextView = findView(R.id.welcome_timer);
        ValueAnimator animator = ValueAnimator.ofInt(3, 0);
        animator.setDuration(3000);
        animator.setInterpolator(new LinearInterpolator());
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                timerTextView.setText(animation.getAnimatedValue() + "s");
            }
        });
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                JumpUtil.startActivity(WelcomeActivity.this, MainActivity.class, getResources().getString(R.string.app_name));
                finish();
            }
        });
        animator.start();
    }
}
